//
//  GSNewsAdsCell.m
//  GameSky
//
//  Created by lanou on 16/1/16.
//  Copyright © 2016年 NiRongfei. All rights reserved.
//

#import "GSNewsAdsCell.h"

#define kMargin 8
#define kImageW (kScreenWidth - 4 * kMargin) / 3

@implementation GSNewsAdsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        // 夜间模式
        self.dk_backgroundColorPicker = DKColorWithRGB(0xffffff, 0x343434);
        
        [self setUp];
        
    }
    return self;
}

- (void)setUp
{
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor grayColor]);
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.titleLabel];
    
    self.bgImage = [[UIImageView alloc] init];
    [self.contentView addSubview:self.bgImage];
    
    self.rightImage = [[UIImageView alloc] init];
    [self.contentView addSubview:self.rightImage];
    
    _titleLabel.sd_layout
    .topSpaceToView(self.contentView,kMargin)
    .leftSpaceToView(self.contentView,kMargin)
    .rightSpaceToView(self.contentView,kMargin)
    .autoHeightRatio(0);
    
    _bgImage.sd_layout
    .leftSpaceToView(self.contentView,kMargin)
    .topSpaceToView(_titleLabel,kMargin)
    .widthIs(kScreenWidth - 2 * kMargin)
    .autoHeightRatio(0.2);

    _rightImage.sd_layout
    .rightSpaceToView(self.contentView,kMargin)
    .widthIs((kScreenWidth - 4 * kMargin)/3)
    .topSpaceToView(_bgImage,kMargin)
    .heightIs(15)
    .widthIs (30);
    
    [_rightImage setImage:[UIImage imageNamed:@"common_Badge_TuiGuang_31x17_UIMode_Day"]];
    [self setupAutoHeightWithBottomView:_rightImage bottomMargin:kMargin];
}

- (void)setModel:(GSNewsListModel *)model
{
    _model = model;
    self.titleLabel.text = model.title;
    [self.bgImage sd_setImageWithURL:[NSURL URLWithString:model.thumbnailURLsArray.firstObject] placeholderImage:kPHImage];
}

@end
